package com.ap.core.webservice.managepayment;


import javax.jws.WebParam;

import com.ap.core.message.service.CoreResponseInfo;
import org.joda.time.LocalDateTime;

import com.ap.core.business.info.ValidationInfo;
import com.ap.core.cxf.jaxb.common.APCORE1FaultDetailsType;
import com.ap.core.cxf.jaxb.managepayment.ConfirmPayment1Request;
import com.ap.core.cxf.jaxb.managepayment.ConfirmPayment1Response;
import com.ap.core.cxf.jaxb.managepayment.ConfirmPaymentMsgHdrType;
import com.ap.core.cxf.jaxb.managepayment.RetrieveRTP1Request;
import com.ap.core.cxf.jaxb.managepayment.RetrieveRTP1Response;
import com.ap.core.exception.BusinessFailureException;
import com.ap.core.message.info.PaymentResponseMessageInfo;
import com.ap.core.message.info.RequestMessageInfo;
import com.ap.core.webservice.BaseWSService;
import com.core.ap.wsdl.managepaymentservice_1.ConfirmPayment1Fault;
import com.core.ap.wsdl.managepaymentservice_1.ManagePayment1PortType;
import com.core.ap.wsdl.managepaymentservice_1.RetrieveRTP1Fault;

/**
 * Implementation class for {@link com.core.ap.wsdl.managepaymentservice_1.ManagePayment1PortType}
 */
public class ManagePaymentWebServiceImpl<AI> extends BaseWSService<RequestMessageInfo<?>, PaymentResponseMessageInfo, AI> implements ManagePayment1PortType {

	

	

    public ConfirmPayment1Response confirmPayment1(@WebParam(partName = "parameters", name = "ConfirmPayment_1Request", targetNamespace = "http://ap.core.com/xsd/managepaymentdata_1") ConfirmPayment1Request confirmPayment1Request)
    		throws ConfirmPayment1Fault {
    	CoreResponseInfo<PaymentResponseMessageInfo, AI> coreResponseInfo;
        LOG.info("Starting processing in ap core at time: " + System.currentTimeMillis() + " for message type = " + confirmPayment1Request.getMsgHdr().getMsgType().name());
    	try {
    		coreResponseInfo =   (CoreResponseInfo<PaymentResponseMessageInfo, AI>) messageProcessor.process(confirmPayment1Request, new ConfirmPayment1Response());
	        } catch (BusinessFailureException e) {
	        	final APCORE1FaultDetailsType confirmPayment1Fault = buildSOAPFaultType(confirmPayment1Request.getMsgHdr().getMsgType().name(), confirmPayment1Request.getMsgHdr().getMsgId(), e);
	        	throw new ConfirmPayment1Fault(getFaultString(confirmPayment1Request.getMsgHdr().getMsgType().name(), confirmPayment1Request.getMsgHdr().getMsgId()), confirmPayment1Fault);            
	        } catch (Exception e) {
	        	final APCORE1FaultDetailsType confirmPayment1Fault = buildSOAPFaultType(confirmPayment1Request.getMsgHdr().getMsgType().name(), confirmPayment1Request.getMsgHdr().getMsgId(),  e);
	            throw new  ConfirmPayment1Fault(getFaultString(confirmPayment1Request.getMsgHdr().getMsgType().name(), confirmPayment1Request.getMsgHdr().getMsgId()), confirmPayment1Fault);           
	        }
        LOG.info("Finishing processing in ap core at time: " + System.currentTimeMillis() + " for message type = " + confirmPayment1Request.getMsgHdr().getMsgType().name());
    	 return (ConfirmPayment1Response) coreResponseInfo.getResponse();
    }

    @Override
    public RetrieveRTP1Response retrieveRTP1(
            @WebParam(partName = "parameters", name = "RetrieveRTP_1Request", targetNamespace = "http://ap.core.com/xsd/managepaymentdata_1") RetrieveRTP1Request retrieveRTP1Request)
            throws RetrieveRTP1Fault {
        CoreResponseInfo<PaymentResponseMessageInfo, AI> coreResponseInfo;
        LOG.info("Starting processing in ap core at time: " + System.currentTimeMillis() + " for message type = " + retrieveRTP1Request.getMsgHdr().getMsgType().name());
        try {
            coreResponseInfo =   (CoreResponseInfo<PaymentResponseMessageInfo, AI>) messageProcessor.process(retrieveRTP1Request, new RetrieveRTP1Response());
       
            } catch (BusinessFailureException e) {
            	final APCORE1FaultDetailsType retrieveRTP1Fault = buildSOAPFaultType(retrieveRTP1Request.getMsgHdr().getMsgType().name(), retrieveRTP1Request.getMsgHdr().getMsgId(), e);
            	throw new RetrieveRTP1Fault(getFaultString(retrieveRTP1Request.getMsgHdr().getMsgType().name(), retrieveRTP1Request.getMsgHdr().getMsgId()), retrieveRTP1Fault);            
            } catch (Exception e) {
            	LOG.error("Exception occurred during retrieve RTP operation",e);
                final APCORE1FaultDetailsType retrieveRTP1Fault = buildSOAPFaultType(retrieveRTP1Request.getMsgHdr().getMsgType().name(), retrieveRTP1Request.getMsgHdr().getMsgId(),  e);
                throw new  RetrieveRTP1Fault(getFaultString(retrieveRTP1Request.getMsgHdr().getMsgType().name(), retrieveRTP1Request.getMsgHdr().getMsgId()), retrieveRTP1Fault);           
            }
        LOG.info("Finishing processing in ap core at time: " + System.currentTimeMillis() + " for message type = " + retrieveRTP1Request.getMsgHdr().getMsgType().name());
        return (RetrieveRTP1Response)coreResponseInfo.getResponse();
    }
    

}
